<!--#Include File="Include.asp"-->
<!--#Include File="../Class/Cls_Template.asp"--><%
'--------------------------------------
'Power By 方卡在线 @2010-2014 f02
'URL:http://www.fangka.net/
'EMail:admin@ifangka.com
'QQ:861118936
'版权所有 未经允许不得去除本版权信息
'--------------------------------------

Call CheckAdminType("0,1",UType)
Call CheckAdminLimit(ULimit,"s_Rewrite",0)

Set FKTemplate=New Cls_Template

Types=Clng(Request.QueryString("Type"))

Select Case Types
	Case 1
		Call RewriteBox() '伪静态规则列表
	Case 2
		Call RewriteFielCreate() '生成httpd.ini文件
	Case Else
		Call FKFun.ShowErr("未发现功能项！",1)
End Select

'==========================================
'函 数 名：RewriteBox()
'作    用：伪静态规则列表
'==========================================
Sub RewriteBox()
	Temp=Replace(GetRewriteRule(),vbCrlf,"<br />")
%>
<div id="title">伪静态规则</div>
<div id="box">
	<table width="95%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
        <tr>
        	<td height="30" align="center">伪静态规则[<a href="Rewrite.asp?Type=2" target="delete" confirmStr="您确认要生成httpd.ini到站点根目录？" showStr="httpd.ini文件生成成功！"><span style="color:red">生成httpd.ini到网站根目录</span></a>]</td>
       	</tr>
        <tr>
            <td height="30" style="padding:10px;">
<%=Temp%>
			</td>
        </tr>
	</table>
</div>
<div id="bottom">
	<input type="button" onClick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
<%
End Sub

'==========================================
'函 数 名：RewriteFielCreate()
'作    用：生成httpd.ini文件
'==========================================
Sub RewriteFielCreate()
	Temp=GetRewriteRule()
	Call FKFun.CreateFile("/httpd.ini",Temp)
	Response.Write("ok")
End Sub

'==========================================
'函 数 名：GetRewriteRule()
'作    用：伪静态规则组合
'==========================================
Function GetRewriteRule()
	Dim rStr,Rs2
	Set Rs2=Server.Createobject("Adodb.RecordSet")
	
	rStr="[ISAPI_Rewrite]" & vbCrlf
	rStr=rStr&"# 3600 = 1 hour" & vbCrlf
	rStr=rStr&"CacheClockRate 3600" & vbCrlf
	rStr=rStr&"RepeatLimit 32" & vbCrlf
	rStr=rStr&"" & vbCrlf
	
	Sqlstr="Select Fk_Menu_Id,Fk_Menu_Name,Fk_Menu_Dir From [Fk_Menu] Order By Fk_Menu_Id Asc"
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		While Not Rs.Eof
			If Rs("Fk_Menu_Dir")<>"" Then
				rStr=rStr&"# "&Rs("Fk_Menu_Name")&"_伪静态规则" & vbCrlf
				rStr=rStr&"RewriteRule ^"&SiteDir&Rs("Fk_Menu_Dir")&"/(.*)$ "&SiteDir&"Index\.asp\?"&Rs("Fk_Menu_Dir")&"/$1" & vbCrlf
			Else
				rStr=rStr&"# "&Rs("Fk_Menu_Name")&"_伪静态规则" & vbCrlf
				Sqlstr="Select Fk_Module_Id,Fk_Module_Name,Fk_Module_Type,Fk_Module_Model,Fk_Module_Url,Fk_Module_LinkType From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_Menu="&Rs("Fk_Menu_Id")&" And Fk_Module_Level=0 Order By Fk_Module_Order Asc,Fk_Module_Id Asc"
				Rs2.Open Sqlstr,Conn,1,1
				While Not Rs2.Eof
					rStr=rStr&"#   __"&Rs2("Fk_Module_Name")&"_伪静态规则" & vbCrlf
					If Not (Rs2("Fk_Module_Type")=4 And Rs2("Fk_Module_LinkType")=0) Then
						rStr=rStr&"RewriteRule ^"&SiteDir&Rs2("Fk_Module_Url")&"(.*)$ "&SiteDir&"Index\.asp\?"&Rs2("Fk_Module_Url")&"$1" & vbCrlf
					End If
					Rs2.MoveNext
				Wend
				Rs2.Close
			End If
			rStr=rStr&"" & vbCrlf
			Rs.MoveNext
		Wend
	End If
	Rs.Close
	rStr=rStr&"# 专题伪静态规则" & vbCrlf
	rStr=rStr&"RewriteRule ^"&SiteDir&"Subject/(.*)$ "&SiteDir&"Index\.asp\?Subject/$1" & vbCrlf
	rStr=rStr&"" & vbCrlf
	
	GetRewriteRule=rStr
End Function

Call FKFun.PageEnd()
%>
